//
//  UIView+IBInsepectable.swift
//  WHSinaWeiBo
//
//  Created by 王寒 on 16/4/6.
//  Copyright © 2016年 wanghan. All rights reserved.
//

import UIKit


extension UIView{
    
    
    @IBInspectable var cornerRadius: CGFloat {
        get{
            
            return layer.cornerRadius
        }
        
        
        set{
            
            layer.cornerRadius = newValue
            
            if newValue>0 {
                layer.masksToBounds = true
                
            }else{
                layer.masksToBounds = false
            }
            
        }
        
    }
    
    @IBInspectable var borderWidth: CGFloat{
        get{
            return layer.borderWidth
            
        }
        set{
            layer.borderWidth = newValue
        }
    
    }
    
    @IBInspectable var borderColor: UIColor?{
        get{
            if let color = layer.borderColor{
                return UIColor(CGColor: color)
            }
            
            return nil
        }
        
        set{
            layer.borderColor = newValue?.CGColor
        }
    }
}